import java.util.*;

public class Main {
    public static int solution(int[] array) {
        Map<Integer, Integer> freq = new HashMap<>();
        for (int num : array) {
            freq.put(num, freq.getOrDefault(num, 0) + 1);
        }

        Integer number = 0;
        for (Map.Entry<Integer, Integer> entry : freq.entrySet()) {
            Integer key = entry.getKey();
            Integer value = entry.getValue();
            if (value > array.length/2) number=key;
        }

        return number;
    }

    public static void main(String[] args) {
        System.out.println(solution(new int[]{1, 3, 8, 2, 3, 1, 3, 3, 3}) == 3);
    }
}
